*******************************************************************************
* Turnout
*******************************************************************************

use dataset_county, clear

egen id = group(statename countyname)
duplicates drop id, force
reshape i id
reshape j year 
reshape xi frack highfracking
reshape xij turnout
reshape long

forvalues i = 1(1)2 {	
	
	preserve

		if `i' == 2 keep if highfracking == 1
		local mytitle = "All states"
		if `i' == 2 local mytitle = "High-fracking States"
		if `i' == 1 local mytext1 text(55.5 2012 "Never fracked")
		if `i' == 1 local mytext2 text(50 2012 "Ever fracked")
		if `i' == 2 local mytext1
		if `i' == 2 local mytext2
		
		collapse turnout, by(year frack)

		#delimit;
		
		gr tw
			(con turnout year if frack == 1, col(black))
			(con turnout year if frack == 0, col(black) msym(Oh))
			,
				legend(off)
				title(`mytitle')
				plotregion(style(none))
				xline(2005, lpat(dash))
				ylab(, angle(horiz))
				ytitle("")
				xtitle("")
				xlab(1996(4)2016)
				name(g`i', replace)
				`mytext1'
				`mytext2'
				;
		
		#delimit cr

	restore
	
}

gr combine g1 g2, ycommon name(G1, replace) title("(a) Turnout")

*******************************************************************************
* Contributions
*******************************************************************************

use dataset_donors_agg, clear

forvalues i = 1(1)2 {	
	
	preserve

		if `i' == 2 keep if highfracking == 1
		local mytitle = "All States"
		if `i' == 2 local mytitle = "High Fracking States"
		if `i' == 1 local mytext1 text(56 2012 "Never Fracked")
		if `i' == 1 local mytext2 text(49 2012 "Ever Fracked")
		if `i' == 2 local mytext1
		if `i' == 2 local mytext2
		
		collapse ltotamount, by(year frack)

		#delimit;
		
		gr tw
			(con ltotamount year if frack == 1, col(black))
			(con ltotamount year if frack == 0, col(black) msym(Oh))
			,
				legend(off)
				title(`mytitle')
				plotregion(style(none))
				xline(2005, lpat(dash))
				ylab(, angle(horiz))
				ytitle("")
				xlab(2000(4)2014)
				name(g`i', replace)
				xtitle("")
				;
		
		#delimit cr

	restore
	
}

gr combine g1 g2, ycommon name(G2, replace) title("(b) Log (Donations + 1)")

*******************************************************************************
* Combine and save.
*******************************************************************************

gr combine G1 G2, rows(2)

gr export "_output/figureA2.pdf", replace
